package com.damai.utils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public abstract class SingletonMap<T> {
	private Map<String, T> map = new ConcurrentHashMap<String, T>();
	public T get(String key){
		T result = map.get(key);
		if(result==null){
			synchronized (map) {
				result = map.get(key);
				if(result==null){
					result = create(key);
					map.put(key, result);
				}
			}
		}
		return result;
	}
	protected abstract T create(String key);
	
}
